home *** CD-ROM | disk | FTP | other *** search
/ ETO Development Tools 4 / ETO Development Tools 4.iso / Essentials / MacApp Documentation / MacApp.TECH$ Archives / 1990 / Aug 90 / MacApp.Tech$ 8⁄24⁄90 / 1810-Re Multiple Inherita-Aug90 < prev    next >
Encoding:
Text File  |  1991-03-06  |  1.4 KB  |  36 lines  |  [TEXT/GEOL]

  1. Item    0457693                         24-Aug-90        11:41PDT
  2.  
  3. From:   ROSENSTEIN1                     Rosenstein, Larry
  4.  
  5. To:     MACAPP.TECH$                    MacApp Technical
  6.         POWERUP.ENG                     Power Up Software,PRT
  7.  
  8. Sub:    RE>Multiple Inheritance Q
  9.  
  10. Attn:   MacApp Tech
  11. Attn: James Plamondon
  12. SentBy: Larry Rosenstein
  13.         Reply to:   RE>Multiple Inheritance Ques
  14. I think TCardFace and TCardBack are reasonable classes.  TCard, however, is
  15. not a kind of TCardFace or TCardBack, and shouldn't inherit from either.  To
  16. me, this is a clear case where you wouldn't use multiple inheritance.
  17.  
  18. A card contains a face and back, and an instance of TCard should have fields
  19. for its face and back.  If the program isn't allowed to see the face, then its
  20. face field would be NIL.  (The dealer would assign random numbers to the cards
  21. so that when a card is turned over it can be given its proper TCardFace
  22. instance.)
  23.  
  24. Geoff's example is probably the more likely case where multiple inheritance
  25. would be used.  (Combining behavior for more than one existing class.)  Even
  26. then multiple inheritance isn't necessary; one could inherit directly from the
  27. "primary" class and delegate behavior to the "secondary" classes.  This allows
  28. you to reuse the code of the secondary classes.
  29.  
  30. Inheritance should only be used for expressing type relationships between
  31. classes.  It shouldn't be used just as a mechanism for reusing code.
  32.  
  33. Larry Rosenstein
  34.  
  35.  
  36.